﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master/admin.Master" AutoEventWireup="true" CodeBehind="application.aspx.cs" Inherits="SampleSite.admin.application" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        table{ border-collapse:collapse; width:100%; border:0px; }
        tr:hover { background-color:rgb(108, 174, 245); }
        tr:hover a { color:white; }
        td a { font-size:12px; font-weight:bold; margin-left:10px; text-decoration:none; color: black; }
    </style>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="welcome_title" runat="server">
    <marquee>欢迎管理员<font color="red" size="5"><%=GetValue("UName") %></font>登录 <%=GetValue("ApplicationName") %></marquee>
    <div style="float: right; padding-right:30px; font-size: 14px; padding-top: 6px; margin-bottom:10px;">
    当前时间：<b id="date"></b>  &nbsp;&nbsp; 
        <a href="default.aspx"><b>返回</b></a>
        <a href="login.aspx"><b>注销</b></a>               
    </div>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="body" runat="server">
    <div data-options="region:'west',split:true,title:'菜单导航'" style="width:200px;">
        <div id="menu" class="easyui-accordion" data-options="fit:true,border:false">
        </div>
    </div>
    <div data-options="region:'center',title:'>><%=GetValue("ApplicationName") %>>>管理员：<%=GetValue("UName") %>'">
        <div id="ttTab" class="easyui-tabs" data-options="tools:'#tab-tools',fit:true,border:false" style="height:auto">
	    </div>
    </div>

    <script type="text/javascript">
        function Initialize() {
            var tab = $('#ttTab');
            tab.tabs({});
            var strHtml = '<iframe id="frmWorkArea" width="100%" height="98%" frameborder="0" scrolling="yes" src="/admin/welcome.html"></iframe>';
            $('#ttTab').tabs('add', {
                title: '欢迎界面',
                content: strHtml,
                iconCls: 'icon-save',
                closable: false,
            });

            var func = function () {
                var year = new Date().getFullYear();
                var Month = new Date().getMonth() + 1;
                var Day = new Date().getDate();
                var Time = new Date().toLocaleTimeString();
                var AddDate = year + "年" + Month + "月" + Day + "日,时间:" + Time;
                $('#date').text(AddDate);
            };
            func();
            setInterval(func, 1000);
        }

        $(function () {
            Initialize();

            BindMenuDataGroupType();
        });

        //绑定前台菜单栏
        function BindMenuDataGroupType() {
            //根据异步读取发送过来的Json字符串
            $.getJSON(
                '/admin/ajax/getmenus.ashx',
                {
                    random: Math.random(),
                    AppId: '<%=this.AppId%>'
                },
                function (data) {
                    //实现在菜单拦中的显示,遍历节点集合
                    for (var i = 0; i < data.length; i++) {
                        var groupInfo = data[i]; //拿到组的信息

                        var strMenuItemHTMl = '<div><table>';
                        for (var j = 0; j < groupInfo.MenuItems.length; j++) {
                            var menuItem = groupInfo.MenuItems[j];
                            strMenuItemHTMl += '<tr onclick="onTrClick(this)"><td><a href="javascript:void(0)" onclick="onAClick(this)" src="' + menuItem.Url + '" class="menuLink">' + menuItem.MenuName + '</a></td></tr>';
                        }
                        strMenuItemHTMl += '</table></div>';
                        
                        //EasyUI添加节点
                        $("#menu").accordion('add', {
                            title: groupInfo.GroupName,
                            content: strMenuItemHTMl,
                            selected: false
                        });
                    }
                });
        }

        function onAClick(n) {
            var a = $(n);

            //获取按钮里面的Src属性
            var src = a.attr("src");

            //将主框架的iframe跳转到菜单指向的地址，$("#frmWorkArea").attr("src", src);
            //
            //Tab页面添加页面标签，每当单击左边的导航栏的时候跳转
            var titleShow = a.text();

            openTab(src, titleShow);
        }

        function onTrClick(n) {
            onAClick($(n).find('a.menuLink')[0]);
        }

        function openTab(src, titleShow) {

            var strHtml = '<iframe id="frmWorkArea" width="100%" height="98%" frameborder="0" scrolling="yes" src="' + src + '"></iframe>';
            //判断Tab标签中是否有相同的数据标签
            var isExist = $("#ttTab").tabs('exists', titleShow);
            if (!isExist) {
                $("#ttTab").tabs('add', {
                    title: titleShow,
                    content: strHtml,
                    iconCls: 'icon-save',
                    closable: true,
                });
            }
            else {
                $('#ttTab').tabs('select', titleShow);
            }
        }

        //读取动态时间的变化
        function ReadDateTimeShow() {
            var year = new Date().getFullYear();
            var Month = new Date().getMonth() + 1;
            var Day = new Date().getDate();
            var Time = new Date().toLocaleTimeString();
            var AddDate = year + "年" + Month + "月" + Day + "日,时间:" + Time;
            $("#date").text(AddDate);
        }
    </script>
</asp:Content>

